package com.pro.controller;

import com.pro.pojo.JsUserFeedback;
import com.pro.pojo.JsonData;
import com.pro.service.JsUserFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author 李佳豪
 * @date 2022/1/13 19:10
 * 反馈列表
 */
@RestController
@RequestMapping("/JsUserFeedback")
public class JsUserFeedbackController {
    @Autowired
    JsUserFeedbackService jsUserFeedbackService;
    /**
     * @author 李佳豪
     * @date 2022/1/13 19:09
     */
    @RequestMapping(value = "/getAllJsUserFeedback")
    public JsonData getAllJsUserFeedback(JsUserFeedback param){
        List<JsUserFeedback> allJsUserFeedback = jsUserFeedbackService.getAllJsUserFeedback(param);
        return allJsUserFeedback!=null?JsonData.buildSuccess(allJsUserFeedback):JsonData.buildError("服务器异常");
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 14:11
     * 修改反馈状态
     */
    @RequestMapping(value = "/updateFeedbackStatus")
    public JsonData updateFeedbackStatus(JsUserFeedback param){
        boolean updateFeedbackStatus = jsUserFeedbackService.updateFeedbackStatus(param);
        return updateFeedbackStatus!=false?JsonData.buildSuccess(true):JsonData.buildError("服务器异常");
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 15:30
     * 根据id删除反馈信息
     */
    @RequestMapping(value = "/DeleteFeedbackById")
    public JsonData DeleteFeedbackById(Integer feedbackId){
        boolean DeleteFeedbackById = jsUserFeedbackService.DeleteFeedbackById(feedbackId);
        return DeleteFeedbackById!=false?JsonData.buildSuccess(true):JsonData.buildError("服务器异常");
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 15:42
     * 统计个数
     */
    @RequestMapping(value = "/feedbackCount")
    public JsonData feedbackCount(){
        Map<String, Object> map = jsUserFeedbackService.feedbackCount();
        return map!=null?JsonData.buildSuccess(map):JsonData.buildError("服务器异常");
    }
    /**
     * @author 李佳豪
     * @date 2022/1/14 15:55
     * 根据状态查询对应反馈
     */
    @RequestMapping(value = "/QueryByStatusFeedback")
    public JsonData QueryByStatusFeedback(Integer stayExamine,Integer alreadyExamine){
        List<JsUserFeedback> jsUserFeedbacks = jsUserFeedbackService.QueryByStatusFeedback(stayExamine,alreadyExamine);
        return jsUserFeedbacks!=null?JsonData.buildSuccess(jsUserFeedbacks):JsonData.buildError("服务器异常");
    }

}
